package com.liuqi.aiagent.transfer.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @author liuqi
 * @date 2025/7/22
 **/
@Getter
@Setter
@ToString
@ApiModel("Agent 聊天记录")
public class AgentChatRecordVo {

    @ApiModelProperty(value = "角色, 用户(user), AI(assistant)")
    private String role;

    @ApiModelProperty(value = "消息内容")
    private String content;

    @ApiModelProperty(value = "AI响应消息")
    private List<ExtendMsg> extendMsgs;

    public AgentChatRecordVo() {
    }

    public AgentChatRecordVo(String role, String content) {
        this.role = role;
        this.content = content;
    }

    public AgentChatRecordVo(String role, String content, List<ExtendMsg> extendMsgs) {
        this.role = role;
        this.content = content;
        this.extendMsgs = extendMsgs;
    }

    public static AgentChatRecordVo userMsg(String content) {
        return new AgentChatRecordVo("user", content);
    }

    public static AgentChatRecordVo aiMsg(String content, List<ExtendMsg> extendMsgs) {
        return new AgentChatRecordVo("assistant", content, extendMsgs);
    }

    @Getter
    @Setter
    @ToString
    @ApiModel("一轮对话中, AI的响应消息可能有思考内容和工具调用. 由AiMsg管理")
    public static class ExtendMsg {
        @ApiModelProperty(value = "AI消息类型, 思考内容(think), 工具调用(function)")
        private String type;

        ExtendMsg(String type) {
            this.type = type;
        }
    }

    @Getter
    @Setter
    @ToString
    @ApiModel("AI的思考内容")
    public static class Think extends ExtendMsg {
        @ApiModelProperty(value = "思考内容")
        private String think;

        @ApiModelProperty(value = "思考内容耗时")
        private Float duration;

        public Think(String think, Float duration) {
            super("think");
            this.think = think;
            this.duration = duration;
        }
    }

    @Getter
    @Setter
    @ToString
    @ApiModel("AI的工具调用")
    public static class ToolCall extends ExtendMsg {
        @ApiModelProperty(value = "函数调用")
        private Function function;

        public ToolCall(Function function) {
            super("function");
            this.function = function;
        }

        @Getter
        @Setter
        @ToString
        @ApiModel("工具调用")
        public static class Function {
            @ApiModelProperty(value = "工具调用名称")
            private String name;

            @ApiModelProperty(value = "工具调用入参")
            private String arguments;

            public Function(String name, String arguments) {
                this.name = name;
                this.arguments = arguments;
            }
        }
    }

}
